package com.lx.oms.controller.service.impl;

import java.math.BigInteger;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lx.oms.common.entity.Page;
import com.lx.oms.common.entity.Query;
import com.lx.oms.common.entity.R;
import com.lx.oms.common.utils.CommonUtils;
import com.lx.oms.controller.entity.UserIndividualEntity;
import com.lx.oms.controller.manager.UserIndividualManager;
import com.lx.oms.controller.service.UserIndividualService;

/**
 * 个体
 *
 * @author houzhong
 * @date 2018年7月12日 上午11:01:59
 */
@Service("userIndividualService")
public class UserIndividualServiceImpl implements UserIndividualService {

	@Autowired
	private UserIndividualManager userIndividualManager;

	@Override
	public Page<UserIndividualEntity> listUserIndividual(Map<String, Object> params) {
		Query query = new Query(params);
		Page<UserIndividualEntity> page = new Page<>(query);
		userIndividualManager.listUserIndividual(page, query);
		return page;
	}

	@Override
	public R saveUserIndividual(UserIndividualEntity userIndividualEntity) {
		int count = userIndividualManager.saveUserIndividual(userIndividualEntity);
		return CommonUtils.msg(count);
	}

	@Override
	public R getUserIndividualById(BigInteger id) {
		UserIndividualEntity tUserIndividual = userIndividualManager.getUserIndividualById(id);
		return CommonUtils.msg(tUserIndividual);
	}

	@Override
	public R updateUserIndividual(UserIndividualEntity userIndividual) {
		int count = userIndividualManager.updateUserIndividual(userIndividual);
		return CommonUtils.msg(count);
	}

	@Override
	public R batchRemove(String[] id) {
		int count = userIndividualManager.batchRemove(id);
		return CommonUtils.msg(id, count);
	}

}
